fix(json-chat): suppress empty-state flash while entries are loading - #84
Merged
Conversation
The wire snapshot ships sessions with stripped entries to keep initial-load latency bounded; the renderer lazy-fetches per session on first mount. Between mount and the entriesSeeded dispatch, the empty condition (entries=[] && !busy) was true, so the bright sparkle empty- state would render for ~one frame before messages appeared. Add an entriesHydrated boolean to JsonClaudeSession that the reducer flips true on entriesSeeded and stripJsonClaudeEntries resets to false. The renderer gates the empty-state on it, rendering null during the loading window (a spinner would itself be a flash). Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
The previous commit gated the empty-state on `entriesHydrated`, but the `jsonClaude:getEntries` handler only dispatched `entriesSeeded` when the session had non-empty entries — so brand-new (truly empty) sessions never flipped hydrated to true, and the empty-state card never appeared. Always dispatch when the session exists. The reducer handles the empty payload fine; the cost is one extra dispatch per new-tab open. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
6 tasks
frenchie4111
added a commit
that referenced
this pull request
May 25, 2026
PR #84 added the entriesHydrated gate to suppress the empty-state flash, but the gating made the entire ternary return null on a fresh chat mount (entries=[], !busy, entriesHydrated=false). The scroll container was left with no firstElementChild, so the useLayoutEffect that attaches the ResizeObserver — mounted once with empty deps — found nothing to observe and never re-ran after entries hydrated. From that point on streaming token deltas grew the content but never triggered the snap-to-bottom. Wrap the conditional in a stable min-h-full flex-col div so the RO always has a firstElementChild. The empty-state's previous min-h-full referenced the scroll container; with a wrapper in between, switch it to flex-1 so it fills the wrapper's column and the sparkle card stays centered. Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
What are we going to build today?sparkle empty-state would flash for a frame between mount and the lazygetJsonClaudeEntriesfetch landing — the wire snapshot ships sessions with stripped entries (seestripJsonClaudeEntries), andentries.length === 0 && !busywas indistinguishable from "truly empty session" during that window.entriesHydrated: booleantoJsonClaudeSession. The reducer flips it true onjsonClaude/entriesSeeded(even when the seeded array is empty, so brand-new tabs still show the empty-state).stripJsonClaudeEntriesresets it to false alongside emptyingentries, with reference identity preserved when no field would actually change.JsonModeChat.tsxonentriesHydrated. During the loading window we rendernullinstead — a spinner's appear-then-disappear would itself be a flash on the typical sub-100ms fetch.Test plan
npm run typechecknpx electron-vite buildnpx vitest run src/shared/state src/main/json-claude-status-deriver.test.ts(505 tests pass; new tests cover hydrated default, entriesSeeded with empty array, strip reset, strip reference identity)npm run dev: open a Chat tab with existing history — no sparkle-circle flashnpm run dev: create a new Chat tab — empty-state still appears once the (empty) entries fetch completesnpm run dev: Cmd+R reload on a tab with history — still no flash🤖 Generated with Claude Code